//
//  ViewController.m
//  Api
//
//  Created by Justsoso on 16/3/28.
//  Copyright © 2016年 Justsoso. All rights reserved.
//

#import "ViewController.h"
#import "NetManager.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UITextView *textView;

@property (weak, nonatomic) IBOutlet UITextField *fromTextField;
@property (weak, nonatomic) IBOutlet UITextField *toTextField;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)btnPressed:(id)sender
{
    [NetManager requestInfoByPersonId:self.textField.text successBlock:^(NSString *result) {
        self.textView.text = result;
    } failBlock:^(NSError *error) {
        self.textView.text = [error localizedDescription];
    }];
}
- (IBAction)btn2Pressed:(id)sender
{
    [NetManager requestNumber:self.textField.text successBlock:^(NSString *result) {
        self.textView.text = result;
    } failBlock:^(NSError *error) {
        self.textView.text = [error localizedDescription];
    }];
}
- (IBAction)btn3Pressed:(id)sender
{
    [NetManager requestWeatherByCityName:self.textField.text successBlock:^(NSString *result) {
        self.textView.text = result;
    } failBlock:^(NSError *error) {
        self.textView.text = [error localizedDescription];
    }];
}
- (IBAction)btn4Pressed:(id)sender
{
    [NetManager requestCurrencyByCamount:self.textField.text fromMoney:self.fromTextField.text toMoney:self.toTextField.text successBlock:^(NSString *result) {
        self.textView.text = result;
    } failBlock:^(NSError *error) {
        self.textView.text = [error localizedDescription];
    }];
}

@end
